<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>10-setTimeout</title>
</head>
<body>
    <button>点击停止定时器</button>
    <script>
        /* 
            清除定时器：clearTimeout
        */
       console.log('安装了炸弹');
       let timer = setInterval(function(){
           console.log('炸弹爆炸了');
       },2000);

       let button = document.querySelector('button');
       button.addEventListener('click',function(){
           console.log('拆除炸弹');
           clearTimeout(timer);
       });
    </script>
</body>
</html>